package com.zhixi100.framework.utils;


import com.zhixi100.framework.common.ObjectRestResponse;
import com.zhixi100.framework.contstants.RestCodeConstants;

/**
 * @author tommy
 * @date 2017/08/17
 */
public class RestResponseUtils {

    /**
     * 获取成功信息
     *
     * @return
     */
    public static ObjectRestResponse success() {
        ObjectRestResponse res = new ObjectRestResponse();
        res.setRel(true);
        res.setStatus(RestCodeConstants.SUCCESS_CODE);
        res.setMessage(RestCodeConstants.SUCCESS_CODE_MESSAGE);
        return res;

    }

    /**
     * 获取成功信息
     *
     * @return
     */
    public static ObjectRestResponse success(Object obj) {
        ObjectRestResponse res = new ObjectRestResponse();
        res.setRel(true);
        res.setData(obj);
        res.setStatus(RestCodeConstants.SUCCESS_CODE);
        res.setMessage(RestCodeConstants.SUCCESS_CODE_MESSAGE);
        return res;

    }

    /**
     * 获取成功信息
     *
     * @return
     */
    public static ObjectRestResponse success(String code, String msg, Object obj) {
        ObjectRestResponse res = new ObjectRestResponse();
        res.setRel(true);
        res.setData(obj);
        res.setStatus(Integer.valueOf(code));
        res.setMessage(msg);
        return res;

    }


    /**
     * 获取失败信息
     *
     * @return
     */
    public static ObjectRestResponse fail() {
        ObjectRestResponse res = new ObjectRestResponse();
        res.setStatus(100);
        res.setRel(false);
        res.setMessage("失败");
        return res;
    }

    /**
     * 获取失败信息
     *
     * @return
     */
    public static ObjectRestResponse fail(int status,String message,Object obj) {
        ObjectRestResponse res = new ObjectRestResponse();
        res.setRel(false);
        res.setData(obj);
        res.setStatus(status);
        res.setMessage(message);
        return res;
    }

    /**
     * 获取失败信息
     *
     * @return
     */
    public static ObjectRestResponse fail(int status, String message) {
        ObjectRestResponse res = new ObjectRestResponse();
        res.setRel(false);
        res.setStatus(status);
        res.setMessage(message);
        return res;
    }

    /**
     * 获取失败信息
     *
     * @return
     */
    public static ObjectRestResponse fail(String status, String message) {
        ObjectRestResponse res = new ObjectRestResponse();
        res.setRel(false);
        res.setStatus(Integer.valueOf(status));
        res.setMessage(message);
        return res;
    }

}
